function Analysis_2_Figures(ResultName,Folder)

% load('Result_Baseline.mat');
% Folder          =   'TableGraphs\\IRF_Baseline\\';
load([ResultName,'.mat']);
mkdir(Folder);

% Setup
T_IRF           =   12;
List_Shock      =   {'Eps_Eta_M_dom','Eps_Eta_M_ext','Eps_Eta_Y_H',...
                     'Eps_Eta_Z','Eps_Eta_Z_N','Eps_Eta_Z_H'};


%% Aggregate Variables
N_col       =   1;
N_row       =   1;
fig_size    =   [N_col,N_row].*[1,0.75]*1/2.5; 
fig_gap     =   [0.02,0.02];
fig_VMargin =   [0.15,0.02];
fig_HMargin =   [0.15,0.02]; 

fig_SubPlot =   @(ii_vv)subtightplot(N_row,N_col,ii_vv,...
                                     fig_gap,fig_VMargin,fig_HMargin);
LEG         =   @(PH,LabelList)legend(PH,LabelList,'fontsize',8,'interpreter','latex','location','best');
AxFontSize  =   8;
TickFmt     =   '%.2f';
XLabel      =   @(Label)xlabel(Label,'fontsize',8,'interpreter','latex');
YLabel      =   @(Label)ylabel(Label,'fontsize',8,'interpreter','latex');
% Prices
for ii_Irf=1:length(List_Shock)
    SH          =   List_Shock{ii_Irf};
    Fig         =   FigureSetup(['IRF of Rates to ',SH],fig_size);
    ax          =   fig_SubPlot(1);
    ID          =   1;
    Dev_Pir     =   IRF.(SH).Pir;
    Dev_ir      =   IRF.(SH).ir;
    Dev_rr      =   IRF.(SH).rr_dom;
    Dev_dE      =   IRF.(SH).dE;
    TempIrf     =   [Dev_rr;Dev_ir;Dev_Pir;Dev_dE]*100*4;
    TempIrf     =   TempIrf(:,1:T_IRF+1);
    LabelList   =   {'Real Rate','Nominal Rate','Inflation','Exchange Depreciation'};
    List_LineStyle= {'-','--',':','-.';'k','b','r','m';2,2,2,2};
    
    [PH,ax]     =   IRFSoloPlot(TempIrf,List_LineStyle,0,ax,[0;max(TempIrf(:))]);
    ax.YLim     =   [ax.YLim(1),ax.YLim(2)];
    ax.XLim     =   [0,T_IRF];
    ax.YAxis.Exponent   =   0;
    ax.YAxis.TickLabelFormat    =   TickFmt;
    ax.FontSize =   AxFontSize;
    XLabel('Quarter');
    YLabel('Deviation from steady state (annualized pp)');
    LEG(PH,LabelList);

    print('-depsc','-r1000',Fig,[Folder,'Prices_',SH]);
    close(Fig);
end

% Aggregate Demand
for ii_Irf=1:length(List_Shock)
    SH          =   List_Shock{ii_Irf};
    Fig         =   FigureSetup(['IRF of Demand to ',SH],fig_size);
    ax          =   fig_SubPlot(1);
    ID          =   1;
    
    Dev_C       =   IRF.(SH).C;
    Dev_C_H     =   IRF.(SH).C_H;
    Dev_C_F     =   IRF.(SH).C_F;
    Dev_Y_H     =   IRF.(SH).Y_H;
    Dev_p_H     =   IRF.(SH).p_H;
    Dev_p_F     =   IRF.(SH).p_F;
    Dev_Y       =   IRF.(SH).Y;
    
    Export      =   ( MODEL.VAR.Y_H.Dev2Level(Dev_Y_H)-MODEL.VAR.C_H.Dev2Level(Dev_C_H) ).* ...
                    MODEL.VAR.p_H.Dev2Level(Dev_p_H);
    ExportIdx   =   Export./MODEL.VAR.Y.Dev2Level(Dev_Y);
    Dev_Export  =   log(Export)-log( SS.p_H*(SS.Y_H-SS.C_H) );
    Dev_ExportIdx=  ExportIdx-( SS.Y_H-SS.C_H )*SS.p_H/SS.Y;
    Import      =   MODEL.VAR.C_F.Dev2Level(Dev_C_F).*MODEL.VAR.p_F.Dev2Level(Dev_p_F);
    NetExport   =   Export-Import;
    NetExportIdx=   NetExport./MODEL.VAR.Y.Dev2Level(Dev_Y);
    Dev_NetExportIdx ...
                =   NetExportIdx-( SS.p_H*(SS.Y_H-SS.C_H)-SS.p_F*SS.C_F )/SS.Y;
    LabelList   =   {'Aggregate Consumption','Export','Net Export/GDP'};
    List_LineStyle= {'-','--',':';'k','b','r';3,3,3};
    TempIrf     =   [Dev_C;Dev_Export;Dev_NetExportIdx];
    TempIrf     =   TempIrf(:,1:T_IRF+1)*100;
    [PH,ax]     =   IRFSoloPlot(TempIrf,List_LineStyle,0,ax,[0;max(TempIrf(:))]);
%     ax.YLim     =   [ax.YLim(1),max(TempIrf(:))];
    ax.XLim     =   [0,T_IRF];
    ax.YAxis.Exponent   =   0;
    ax.YAxis.TickLabelFormat    =   TickFmt;
    ax.FontSize =   AxFontSize;
    XLabel('Quarter');
    YLabel('Deviation from steady state (pp)');
    LEG(PH,LabelList);
    
    print('-depsc','-r1000',Fig,[Folder,'AggDemand_',SH]);
    close(Fig);
end

% Aggregate Supply
for ii_Irf=1:length(List_Shock)
    SH          =   List_Shock{ii_Irf};
    Fig         =   FigureSetup(['IRF of Supply to ',SH],fig_size);
    ax          =   fig_SubPlot(1);
    ID          =   1;
    
    Dev_Y       =   IRF.(SH).Y;
    Dev_Y_H     =   IRF.(SH).Y_H;
    Dev_Y_N     =   IRF.(SH).Y_N;
    TempIrf     =   [Dev_Y_H;Dev_Y_N]*100;
    TempIrf     =   TempIrf(:,1:T_IRF+1);
    LabelList   =   {'Output, Home Tradable Good','Output, Non-tradable Good'};
    List_LineStyle= {'-','--',':';'k','b','r';3,3,3};
    
    [PH,ax]     =   IRFSoloPlot(TempIrf,List_LineStyle,0,ax,[0;max(TempIrf(:))]);
%     ax.YLim     =   [ax.YLim(1),max(TempIrf(:))];
    ax.XLim     =   [0,T_IRF];
    ax.YAxis.Exponent   =   0;
    ax.YAxis.TickLabelFormat    =   TickFmt;
    ax.FontSize =   AxFontSize;
    XLabel('Quarter');
    YLabel('Deviation from steady state (pp)');
    LEG(PH,LabelList);
    
    print('-depsc','-r1000',Fig,[Folder,'AggSupply_',SH]);
    close(Fig);
end

%% Appendix
VarDict     =   struct('C','Consumption','C_N','Consumption: N','C_H','Consumption: H','C_F','Consumption: F',...
                       'N_N','Hours: N','N_H','Hours: H','w','Wage',......
                       'Y','Output','Y_N','Output: N','Y_H','Output: H','dE','Depreciation',...
                       'ir_dom','Nominal Rate: Domestic','ir_ext','Nominal Rate: Foreign','rr_dom','Real Return: Domestic','rr_ext','Real Return: Foreign',...
                       'Pir','Inflation','Pir_N','Inflation: N','Pir_H','Inflation: H','Pir_F','Inflation: F' ...
                       );
% 'Eta_M_dom','MP: Domestic','Eta_M_ext','MP: Foreign','Eta_Y_H','Demand: Foreign'
% 'Eta_Z','TFP','Eta_Z_N','TFP: N','Eta_Z_H','TFP: H',...'dE_Real','Real Exchange', ...
% 'Bp_dom','Saving: Domestic','Bp_ext','Saving: Foreign',
% 'E','CAD/USD','CPI','CPI', 'T','Transfer','TAU','Tax Rate','B','Gov. Bond','Profit','Profit' ...
                       
VarList     =   fieldnames(VarDict);

% Graph
Num_Var     =   length(VarList);
Num_Shock   =   length(List_Shock);

N_col       =   4;
N_row       =   ceil(Num_Var/N_col);
fig_size    =   [N_col,N_row].*[1,0.75]*1/4;  
fig_gap     =   [0.04,0.03];
fig_VMargin =   [0.03,0.03];
fig_HMargin =   [0.03,0.01]; 

fig_SubPlot =   @(ii_vv)subtightplot(N_row,N_col,ii_vv,...
                                     fig_gap,fig_VMargin,fig_HMargin);
for ii_sh=1:Num_Shock
    SH          =   List_Shock{ii_sh};
    fig_Handle  =   FigureSetup(['IRF-',SH],fig_size);
    for ii_vv=1:Num_Var
        VV              =   VarList{ii_vv};
        ax              =   fig_SubPlot(ii_vv);
        if strcmp(VV,'dE_Real')
            TempIrf         =   IRF.(SH).dE-IRF.(SH).Pir;
        elseif strcmp(VV,'E')
            TempIrf         =   cumsum(IRF.(SH).dE);
        elseif strcmp(VV,'CPI')
            TempIrf         =   cumsum(IRF.(SH).Pir);
        else
            TempIrf         =   IRF.(SH).(VV);
        end
        TempIrf(abs(TempIrf)<1e-6)  =   0;
        List_LineStyle  =   {'-';'k';2};
        [PH,ax]         =   IRFSoloPlot(TempIrf(:,1:T_IRF+1),List_LineStyle,1,ax);
        ax.XLim         =   [0,T_IRF];
        ax.FontSize     =   6;
        title(VarDict.(VV),'fontsize',8,'interpreter','latex');

    end

    print(fig_Handle,[Folder,'Full_',SH],'-depsc'); 
    close(fig_Handle);
end

%% Collect the Key Results into Tables
Num_Shock   =   length(List_Shock);
RowNames    =   {'Inflation','Exchange Rate','Aggregate Consumption'};
TableArray  =   zeros(length(RowNames),Num_Shock);

for ii_sh=1:Num_Shock
    SH          =   List_Shock{ii_sh};
    [~,MaxIdx]  =   max(abs(IRF.(SH).C));
    TableArray(:,ii_sh) ...
                =   [IRF.(SH).Pir(MaxIdx)*100*4;...
                     sum(IRF.(SH).dE(1:MaxIdx))*100;...
                     IRF.(SH).C(MaxIdx)*100];
end
KeyResults  =   array2table(TableArray,'RowNames',RowNames,'VariableNames',List_Shock);

writetable(KeyResults,[Folder,'KeyResults.xlsx'],'WriteRowNames',true);